package com.jimline.newRate.core;

import java.util.ArrayList;

public abstract class ResBase {
	protected static final float m_startMoney = 3500.0f;
	
    public static final RateTable m_rateTable[] = {
    	new RateTable(80000.0f , 0.45f, 13505.0f, true),
        new RateTable(55000.0f , 0.35f,  5505.0f, true),
        new RateTable(35000.0f , 0.30f,  2755.0f, true),
        new RateTable(9000.0f  , 0.25f,  1005.0f, true),
        new RateTable(4500.0f  , 0.20f,   555.0f, true),
        new RateTable(1500.0f  , 0.10f,   105.0f, true),
        new RateTable(0.0f     , 0.03f,     0.0f, true)
    };
    
    public float getStartMoney()
    {
        return m_startMoney;
    }
    
    public float calculateRate(float incoming, float outgoing){
    	float moneyTmp = incoming - outgoing - m_startMoney;
    	
        for (int i = 0; i < m_rateTable.length; ++i) {
            if (moneyTmp > m_rateTable[i].getMinMoney()) {
            	moneyTmp = Math.round((moneyTmp * m_rateTable[i].getRate() - m_rateTable[i].getDeleteNum())*100)/100.0f;
                return moneyTmp;
            }
        }
        return -1;
    }
    
    public abstract ArrayList<String> getIncomingItem();
    public abstract ArrayList<String> getOutgointItem();
}
